<?php require_once 'header.php';
require "backend/Customer.php";
?>

	<div id = "pagecontent">
		<h1>REGISTER PAGE</h1>
		<p>Please Enter information into all fields below.
		</p>
		<?php 
			if(isset($_POST['Email']))
			{
				$usermail = ($_POST['Email']);
				$password = ($_POST['Password']);
				$phone = ($_POST['Phone']);
				$name = ($_POST['name']);
				$address = ($_POST['address']);
				if($usermail == "" || $password == "" || $phone == "" || $name == ""|| $address == "")
				{
					echo "<font size=3 color=red><b>Not all fields were entered</b><p/></font><br/>";
				}
				else if(strlen($phone) != 11)
				{
					echo "<font size=3 color=red><b>Phone number not long enough</b><p/></font><br/>";
				}
				else
				{
					$register = new Customer();
					$result = $register->registerCustomer($usermail, $password, $phone, $name, $address);
					
					if($result == "Accepted")
					{
						echo "$result";
					}
					else 
					{
						echo "$result";
					}
				}
			}
		
		?>
	
		<form action="Register.php" method="post">
		<fieldset>
		
		<br><br>
		<div id = "Email">
			<font color = "red" size = "3">Email : <p/></font>
			<input  name="Email" type="text">
			<p/>
		</div>
		
		<div id = "Password">
			<font color = "red" size = "3">Password : <p/></font>
			<input  name="Password" type="password">
	        
		</div>
		
		<div id = "Phone">
			<font color = "red" size = "3">Phone : <p/></font>
			<input  name="Phone" type="text" maxlength = "11" onKeyPress="return numbersonly(this, event)">
		</div>
		
		<div id ="name">
			<font color = "red" size = "3">Name : <p/></font>
			<input type="text" name='name' />
		</div>
		
		<div id ="address">
			<font color = "red" size = "3">Address : <p/></font>
			<input type="text" name='address' />
		</div>
		
		<p><input type="submit" value="Register" />
		<input type='reset' value='Clear'/>
		</fieldset>
	</form>


	</div><!-- end of pagecontent -->

<?php require_once 'footer.php';?>